package com.wisnews.mapper.sec;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.wisnews.pojo.sec.entity.Permission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 系统权限信息 Mapper 接口
 * </p>
 *
 * @author yuyd
 * @since 2020-12-20
 */
@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("SELECT a.* FROM  t_sec_permission a  LEFT JOIN t_sec_role_permission b ON" +
            " a.permission_id = b.permission_id  WHERE b.role_id = #{operatorRole} ORDER BY a.type,a.pid,sort_id ")
    List<Permission> getPermissionForRole(String operatorRole);

    @Select(" select a.* from t_sec_permission a ${ew.customSqlSegment}")
    IPage<Permission> getPermissionForPage(@Param(Constants.WRAPPER) Wrapper<Permission> lambdaQueryWrapper, IPage<Permission> toPage);

}
